<template>
    <view class="g_content content_box">
        <view class="bg"></view>
        <view class="content p_20">
            <!--        <view class="dis_f_c_c m_b_20">
                        <image src="@/static/img/logo.jpg" style="width: 150rpx;height: 150rpx;border-radius: 20rpx"></image>
                    </view>-->
            <view class="c_f f_s_20 m_t_50 m_l_10">
                <view >嗨，您 好</view>
                <view class="m_t_5">欢 迎 您 使 用 易 讯 宝 库</view>
            </view>
            <view class="dis_f_c_c m_t_100">
                <u-button shape="circle" color="#E1BC6D"  type="primary" open-type="getPhoneNumber" @getphonenumber="phoneSubmit">授权手机号登录</u-button>
            </view>
        </view>
    </view>
</template>

<script>
import { mapGetters, mapMutations } from "vuex";
import { phoneLogin } from "@/sheep/api/login";

export default {
    data() {
        return {
            isLoading:false,
        };
    },
    ...mapMutations({
        setAuth: "user/setAuth",
        setToken: "user/setToken",
    }),
    methods: {
        async phoneSubmit(e) {
/*            uni.showLoading({title:'登录中...'});
            let that = this
            uni.login({
                provider: "weixin",
                success: function (loginRes) {
                    console.log("loginRes", loginRes);
                    let loginBody = {
                        xcxCode: loginRes.code,
                        phoneCode: e.detail.code,
                        clientId: "be7052a7e4f802c20df10a8d131adb12",
                        grantType: "xcxBind",
                        tenantId: "000000",
                    };
                    phoneLogin(loginBody).then((res) => {
                        if (res.code === 200) {
                            that.setToken(res.data);
                            uni.switchTab({
                                url: "/pages/index/index",
                            })
                        }
                    });
                },
                fail(res) {
                    uni.hideLoading()
                    console.log(res, "登录失败");
                },
            });*/








        },




        /*        handleLogin(){
                    /!*          uni.switchTab({
                                  url: '/pages/index/index'
                              });*!/
                    let that=this
                    this.$refs.uForm.validate().then(res => {
                        that.isLoading=true
                        let loginBody = {
                            xcxCode: "",
                            isBindPhone: false,
                            clientId: "be7052a7e4f802c20df10a8d131adb12",
                            grantType: "xcx",
                            tenantId: "000000",
                            username:that.model1.userInfo.username,
                            password:that.model1.userInfo.password,
                        };
                        uni.login({
                            provider: "weixin",
                            success: function (loginRes) {
                                loginBody.xcxCode = loginRes.code;
                                loginApi(loginBody).then((res) => {
                                    that.isLoading=false
                                    if (res.code === 200) {
                                        that.$store.commit('user/setToken', res.data.access_token)
                                        if (uni.getStorageSync('bindAgentId')) bindAgentId()
                                        //延迟跳转，否则会报错
                                        setTimeout(()=>{
                                            uni.switchTab({
                                                url: '/pages/index/index'
                                            });
                                        },1000)

                                    }
                                });
                            },
                            fail(res) {
                                console.log(res, "登录失败");
                            },
                        });
                    })

                }*/
    },
};
</script>

<style lang="scss" scoped>
.content_box{
    position: relative;
    .bg{
        background: #E1BC6D;
        height: 20vh;
        border-bottom-right-radius: 118rpx;
    }
    .content{
        width: 100%;
        position: absolute;
        top: 0;
    }
}

</style>
